<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__ADMIN__css/font.css">
    <link rel="stylesheet" href="__ADMIN__css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__js/jq.js"></script>
    <script type="text/javascript" src="__ADMIN__lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__js/xadmin.js"></script>
    {include file='public/ueditor'}
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="__ADMIN__html5.min.js"></script>
    <script src="__ADMIN__respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="cate_name" class="layui-form-label">
                <span class="x-red">*</span>栏目名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="cate_name" name="cate_name" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="seo_cate" class="layui-form-label">
                <span class="x-red">*</span>seo名称
            </label>
            <div class="layui-input-inline">
                <input   style="width: 500px"  type="text" id="seo_cate" name="seo_cate"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="cate_keywords" class="layui-form-label">
                <span class="x-red">*</span>栏目关键字
            </label>
            <div class="layui-input-inline">
                <input style="width: 500px" type="text" id="cate_keywords" name="cate_keywords"   autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="cate_desc" class="layui-form-label">
                <span class="x-red">*</span>栏目描述
            </label>
            <div class="layui-input-inline">
               <textarea style="width: 500px" name="cate_desc" id="cate_desc" class="layui-textarea"></textarea>
            </div>

        </div>
        <div class="layui-form-item">
            <label for="cate_img" class="layui-form-label">
                <span class="x-red">*</span>栏目图片
            </label>
            <div style="display: flex" class="layui-input-block">
                <input style="width: 400px" type="text" id="cate_img" name="cate_img"  autocomplete="off" class="layui-input">
                <button type="button" class="layui-btn" id="test1">上传图片</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="cate_img" class="layui-form-label">
                <span class="x-red">*</span>模型管理
            </label>
            <div  class="layui-input-inline">
                <select name="pattern_id"  class="layui-input">
                {volist name='pattern' id='list'}
                      <option {if $list.selected == 1} selected {/if}    value="{$list.id}">{$list.name}</option>
                {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目类型</label>
            <div class="layui-input-block">
                <input type="radio" name="temp_type"  value="1" title="列表页" checked="" lay-filter="aaa"><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>列表页</div></div>
                <input type="radio" name="temp_type" value="2" title="封面页" lay-filter="aaa"><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>封面页</div></div>
                <input type="radio"  name="temp_type"  value="3" title="链接" lay-filter="aaa"><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>链接</div></div>
            </div>
        </div>
        <div style="display: none"  id="outUrl" class="layui-form-item">
            <label for="index_temp" class="layui-form-label">
                <span class="x-red">*</span>链接地址
            </label>
            <div class="layui-input-inline">
                <input style="width: 500px" type="text" id="out_url" name="out_url" value=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <script>
            layui.use('form', function () {
                var form = layui.form;
                form.on('radio(aaa)', function (data) {
                    var style = $("#outUrl").css('display');
                    if (style == "none"){
                        $("#outUrl").css('display','block') ;
                    }
                    if (data.value == 1|| data.value == 2){
                        $("#outUrl").css('display','none') ;
                    }
                });
            });

        </script>
        <div class="layui-form-item">
            <label for="index_temp" class="layui-form-label">
                <span class="x-red">*</span>封面页模板
            </label>
            <div class="layui-input-inline">
                <input type="text" id="index_temp" name="index_temp" value="index_article.html" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="list_temp" class="layui-form-label">
                <span class="x-red">*</span>列表页模板
            </label>
            <div class="layui-input-inline">
                <input type="text" id="list_temp" name="list_temp"  value="list_article.html"  required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="article_temp" class="layui-form-label">
                <span class="x-red">*</span>内容页模板
            </label>
            <div class="layui-input-inline">
                <input type="text" id="article_temp" name="article_temp" value="article_article.html"  required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="article_temp" class="layui-form-label">
                <span class="x-red">*</span>列表分页
            </label>
            <div class="layui-input-inline">
                <input type="text" id="page" name="page" value="12"  required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="article_temp" class="layui-form-label">
                <span class="x-red">*</span>列表排序
            </label>
            <div class="layui-input-block">
                <input type="radio" name="list_order" value="1" title="ID">
                <input type="radio" name="list_order" value="2" title="TIME" checked>
                <input type="radio" name="list_order" value="3" title="SORT">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="article_temp" class="layui-form-label">
                <span class="x-red">*</span>排序方式
            </label>
            <div class="layui-input-inline">
                <input type="radio" name="order_by" value="1" title="升序" checked>
                <input type="radio" name="order_by" value="2" title="降序">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="editor" class="layui-form-label">
                <span class="x-red">*</span>栏目内容
            </label>
            <div class="layui-input-block">
                <textarea   id="editor" style="height: 400px;width: 1000px"  name="cate_content"> </textarea>
                <script type="text/javascript">
                    //实例化编辑器
                    var ue = UE.getEditor('editor');
                </script>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button type="button"  class="layui-btn" lay-filter="add" lay-submit="">
                增加
            </button>
        </div>
    </form>
</div>
<script>
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: "{:url('admin/cate/cateImage')}"
            ,accept: 'images'
            ,size:500
            ,done: function(res){
                //如果上传失败
                if(res.code == 0){
                    return layer.msg('上传成功',{icon:6},function () {
                        $("#cate_img").val(res.img);
                    });
                }else {
                    layer.msg(res.message);
                }
                //上传成功
            }
        });
    });
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data){
            //console.log(data);
            var cateData = $('.layui-form').serialize();
            $.ajax({
                type:'post',
                data:cateData,
                dataType:'json',
                url:"{:url('admin/cate/add')}",
                success:function (data) {
                    if (data.code == 0){
                        layer.alert(data.message, {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            return false;
                        });
                    }else{
                        layer.alert(data.message, {icon: 5});
                        return false;
                    }
                }
            })
        });


    });
</script>
</body>

</html>


